package com.yanqu.road.server.cmd.activity.climbtower;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ClimbTowerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.climbtower.CrossClimbTowerMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_CLIMB_TOWER_TOP_CELL_LIST, desc = "新幻境层数据")
public class CrossClimbTowerTopCellListCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ClimbTowerProto.ClimbTowerCrossTopCellListReqMsg reqMsg = ClimbTowerProto.ClimbTowerCrossTopCellListReqMsg.parseFrom(packet.getBytes());
        ClimbTowerProto.ClimbTowerTopCellListRespMsg.Builder respMsg = CrossClimbTowerMgr.getTopCellList(reqMsg.getActivityId(), packet.getPlayerId());
        respMsg.setMaxTopCell(reqMsg.getMaxTopCell());
        if (reqMsg.hasLastDefeatedRecord()) {
            respMsg.setLastDefeatedRecord(reqMsg.getLastDefeatedRecord());
        }
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.U_CLIMB_TOWER_TOP_CELL_LIST, respMsg));
    }

    @Override
    public void sendData() {

    }
}
